package com.njit.farm.controller;

import com.njit.farm.model.OrderItem;
import com.njit.farm.model.Result;
import com.njit.farm.service.OrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/orderItem/")
public class OrderItemController {

    @Resource
    OrderService orderService;

    @RequestMapping(value = "add",method = RequestMethod.POST)
    public Result add(@RequestBody OrderItem orderItem){
        return orderService.addOrderItem(orderItem);
    }

    @RequestMapping(value = "update",method = RequestMethod.POST)
    public Result update(@RequestBody OrderItem orderItem){
        return orderService.updateOrderItem(orderItem);
    }

    @RequestMapping(value = "delete", method = RequestMethod.GET)
    public Result delete(@RequestParam("oiId") String oiId) {
        return orderService.deleteOrderItem(oiId);
    }

}
